package com.zzy.study.conf;

/**
 * 学习class对象
 * @author eason
 *
 */
public class TestClass {

	public static void main(String[] args) throws ClassNotFoundException {
		
		//通过类的实例调用来获得类对象,在编译器加载
		Person p = new Person();
		Class personClass1 = p.getClass();
		
		//在编译器加载
		Class personClass2 = Person.class;
		//装载连接初始化,在运行时加载
		Class personClass3 = Class.forName("com.zzy.conf.study.Person");
		//装载不连接不初始化
		Class personClass4 = Thread.currentThread().getContextClassLoader().loadClass("com.zzy.conf.study.Person");
	}

}

class Person {
	private static int age;
	private String name;
	
	static {
		age = 20;
		System.out.println("initialize age");
	}
}

